const app = getApp()
const db = wx.cloud.database()
const _ = db.command
Page({
    /**
     * 页面的初始数据
     */
    data: {
        grade: ['大一', '大二', '大三', '大四'],
        index: 0,
        zong: '',
        bmi: '',
        gender: 'male',
        userInfo: {}
    },
    // 表单提交
    submit(e) {
        let { gender, nianji, shengao, tizhong, feihuoliang, zuowei, liding, duan, yuan, yinti } = e.detail.value
        shengao = shengao - 0
        tizhong = tizhong - 0
        feihuoliang = feihuoliang - 0
        zuowei = zuowei - 0
        liding = liding - 0
        duan = duan - 0
        yuan = yuan - 0
        yinti = yinti - 0
        let zong = ''
        let bmi = ''
        let f = ''
        let b = ''
        let d = ''
        let y = ''
        let l = ''
        let z = ''
        let yin = ''
        let zuoweiArr = [24.9, 23.1, 21.3, 19.5, 17.7, 16.3, 14.9, 13.5, 12.1, 10.7, 9.3, 7.9, 6.5, 5.1, 3.7, 2.7, 1.7, 0.7, -0.3, -1.3]
        let zuoweiArr1 = [25.1, 23.3, 21.5, 19.9, 18.2, 16.8, 15.4, 14, 12.6, 11.2, 9.8, 8.4, 7, 5.6, 4.2, 3.2, 2.2, 1.2, 0.2, -0.8]
        let zuoweiArr2 = [25.8, 24, 22.2, 20.6, 19, 17.7, 16.4, 15.1, 13.8, 12.5, 11.2, 9.9, 8.6, 7.3, 6, 5.2, 4.4, 3.6, 2.8, 2]
        let zuoweiArr3 = [26.3, 24.4, 22.4, 21, 19.5, 18.2, 16.9, 15.6, 14.3, 13, 11.7, 10.4, 9.1, 7.8, 6.5, 5.7, 4.9, 4.1, 3.3, 2.5]
        let lidingArr = [273, 268, 263, 256, 248, 244, 240, 236, 232, 228, 224, 220, 216, 212, 208, 203, 198, 193, 188, 183]
        let lidingArr1 = [275, 270, 265, 258, 250, 246, 242, 238, 234, 230, 226, 222, 218, 214, 210, 205, 200, 195, 190, 185]
        let lidingArr2 = [207, 201, 195, 188, 181, 178, 175, 172, 169, 166, 163, 160, 157, 154, 151, 146, 141, 136, 131, 126]
        let lidingArr3 = [208, 202, 196, 189, 182, 179, 176, 173, 170, 167, 164, 161, 158, 153, 152, 147, 142, 137, 132, 127]
        // 男生
        if (gender == 'male') {
            if (nianji == 0 || nianji == 1) {
                console.log(feihuoliang);
                //肺活量计算
                if (feihuoliang >= 5040) {
                    f = 15
                } else if (4920 <= feihuoliang) {
                    console.log('111');
                    f = 14.25
                } else if (4800 <= feihuoliang) {
                    f = 13.5
                } else if (4550 <= feihuoliang) {
                    f = 12.75
                } else if (4300 <= feihuoliang) {
                    f = 12
                } else if (4180 <= feihuoliang) {
                    f = 11.7
                } else if (4060 <= feihuoliang) {
                    f = 11.4
                } else if (3940 <= feihuoliang) {
                    f = 11.1
                } else if (3820 <= feihuoliang) {
                    f = 10.8
                } else if (3700 <= feihuoliang) {
                    f = 10.5
                } else if (3580 <= feihuoliang) {
                    f = 10.2
                } else if (3460 <= feihuoliang) {
                    f = 9.9
                } else if (3340 <= feihuoliang) {
                    f = 9.6
                } else if (3220 <= feihuoliang) {
                    f = 9.3
                } else if (3100 <= feihuoliang) {
                    f = 9
                } else if (2940 <= feihuoliang) {
                    f = 7.5
                } else if (2780 <= feihuoliang) {
                    f = 6
                } else if (2620 <= feihuoliang) {
                    f = 4.5
                } else if (2460 <= feihuoliang) {
                    f = 3
                } else if (2300 <= feihuoliang) {
                    f = 1.5
                } else {
                    f = 0
                }
                console.log(zuowei, '坐立', liding, '立定', duan, '50mi', yuan, '1000mi', yinti, '引体');
                // 引体向上计算
                switch (yinti) {
                    case 0:
                    case 1:
                    case 2:
                    case 3:
                    case 4: yin = 0; break;
                    case 5: yin = 1; break
                    case 6: yin = 2; break
                    case 7: yin = 3; break
                    case 8: yin = 4; break
                    case 9: yin = 5; break
                    case 10: yin = 6; break
                    case 11: yin = 6.4; break
                    case 12: yin = 6.8; break
                    case 13: yin = 7.2; break
                    case 14: yin = 7.6; break
                    case 15: yin = 8; break
                    case 16: yin = 8.5; break
                    case 17: yin = 9; break
                    case 18: yin = 9.5; break
                    case 19: yin = 10; break
                    default: yin = 10; break
                }
                //50米跑
                if (duan <= 6.7) {
                    d = 20
                } else if (duan <= 6.8) {
                    d = 19
                } else if (duan <= 6.9) {
                    d = 18
                } else if (duan <= 7) {
                    d = 17
                } else if (duan <= 7.1) {
                    d = 16
                } else if (duan <= 7.3) {
                    d = 15.6
                } else if (duan <= 7.5) {
                    d = 15.2
                } else if (duan <= 7.7) {
                    d = 14.8
                } else if (duan <= 7.9) {
                    d = 14.4
                } else if (duan <= 8.1) {
                    d = 14
                } else if (duan <= 8.3) {
                    d = 13.6
                } else if (duan <= 8.5) {
                    d = 13.2
                } else if (duan <= 8.7) {
                    d = 12.8
                } else if (duan <= 8.9) {
                    d = 12.4
                } else if (duan <= 9.1) {
                    d = 12
                } else if (duan <= 9.3) {
                    d = 10
                } else if (duan <= 9.5) {
                    d = 8
                } else if (duan <= 9.7) {
                    d = 6
                } else if (duan <= 9.9) {
                    d = 4
                } else if (duan <= 10.1) {
                    d = 2
                } else {
                    d = 0
                }
                if (!duan) {
                    d = 0
                }
                // 1000米长跑
                if (yuan <= 197) {
                    y = 20
                } else if (yuan <= 202) {
                    y = 19
                } else if (yuan <= 207) {
                    y = 18
                } else if (yuan <= 214) {
                    y = 17
                } else if (yuan <= 222) {
                    y = 16
                } else if (yuan <= 227) {
                    y = 15.6
                } else if (yuan <= 232) {
                    y = 15.2
                } else if (yuan <= 237) {
                    y = 14.8
                } else if (yuan <= 242) {
                    y = 14.4
                } else if (yuan <= 247) {
                    y = 14
                } else if (yuan <= 252) {
                    y = 13.6
                } else if (yuan <= 257) {
                    y = 13.2
                } else if (yuan <= 262) {
                    y = 12.8
                } else if (yuan <= 267) {
                    y = 12.4
                } else if (yuan <= 272) {
                    y = 12
                } else if (yuan <= 292) {
                    y = 10
                } else if (yuan <= 312) {
                    y = 8
                } else if (yuan <= 332) {
                    y = 6
                } else if (yuan <= 352) {
                    y = 4
                } else if (yuan <= 372) {
                    y = 2
                } else {
                    y = 0
                }
                if (!yuan) {
                    y = 0
                }
                // 立定跳远
                if (liding >= lidingArr[0]) {
                    l = 10
                } else if (lidingArr[1] <= liding) {
                    l = 9.5
                } else if (lidingArr[2] <= liding) {
                    l = 9
                } else if (lidingArr[3] <= liding) {
                    l = 8.5
                } else if (lidingArr[4] <= liding) {
                    l = 8
                } else if (lidingArr[5] <= liding) {
                    l = 7.8
                } else if (lidingArr[6] <= liding) {
                    l = 7.6
                } else if (lidingArr[7] <= liding) {
                    l = 7.4
                } else if (lidingArr[8] <= liding) {
                    l = 7.2
                } else if (lidingArr[9] <= liding) {
                    l = 7
                } else if (lidingArr[10] <= liding) {
                    l = 6.8
                } else if (lidingArr[11] <= liding) {
                    l = 6.6
                } else if (lidingArr[12] <= liding) {
                    l = 6.4
                } else if (lidingArr[13] <= liding) {
                    l = 6.2
                } else if (lidingArr[14] <= liding) {
                    l = 6
                } else if (lidingArr[15] <= liding) {
                    l = 5
                } else if (lidingArr[16] <= liding) {
                    l = 4
                } else if (lidingArr[17] <= liding) {
                    l = 3
                } else if (lidingArr[18] <= liding) {
                    l = 2
                } else if (lidingArr[19] <= liding) {
                    l = 1
                } else {
                    l = 0
                }
                // 坐位体前屈
                if (zuowei >= zuoweiArr[0]) {
                    z = 10
                } else if (zuoweiArr[1] <= zuowei) {
                    z = 9.5
                } else if (zuoweiArr[2] <= zuowei) {
                    z = 9
                } else if (zuoweiArr[3] <= zuowei) {
                    z = 8.5
                } else if (zuoweiArr[4] <= zuowei) {
                    z = 8
                } else if (zuoweiArr[5] <= zuowei) {
                    z = 7.8
                } else if (zuoweiArr[6] <= zuowei) {
                    z = 7.6
                } else if (zuoweiArr[7] <= zuowei) {
                    z = 7.4
                } else if (zuoweiArr[8] <= zuowei) {
                    z = 7.2
                } else if (zuoweiArr[9] <= zuowei) {
                    z = 7
                } else if (zuoweiArr[10] <= zuowei) {
                    z = 6.8
                } else if (zuoweiArr[11] <= zuowei) {
                    z = 6.6
                } else if (zuoweiArr[12] <= zuowei) {
                    z = 6.4
                } else if (zuoweiArr[13] <= zuowei) {
                    z = 6.2
                } else if (zuoweiArr[14] <= zuowei) {
                    z = 6
                } else if (zuoweiArr[15] <= zuowei) {
                    z = 5
                } else if (zuoweiArr[16] <= zuowei) {
                    z = 4
                } else if (zuoweiArr[17] <= zuowei) {
                    z = 3
                } else if (zuoweiArr[18] <= zuowei) {
                    z = 2
                } else if (zuoweiArr[19] <= zuowei) {
                    z = 1
                } else {
                    z = 0
                }
                // 求值bmi
                bmi = tizhong / Math.pow(shengao, 2)
                // BMI
                if (bmi >= 28) {
                    b = 9
                } else if (bmi >= 24) {
                    b = 12
                } else if (bmi >= 17.9) {
                    b = 15
                } else {
                    b = 12
                }

                if (!bmi) {
                    b = 0
                    bmi = 0
                }
                bmi = bmi.toFixed(2)
                zong = b + f + z + l + d + y + yin
                console.log(b, 'bmi', f, '肺活量', z, '坐立', l, '立定', d, '50米', y, '1000米', yin, '引体');
            } else {
                //肺活量计算
                if (feihuoliang >= 5140) {
                    f = 15
                } else if (5020 <= feihuoliang) {
                    f = 14.25
                } else if (4900 <= feihuoliang) {
                    f = 13.5
                } else if (4650 <= feihuoliang) {
                    f = 12.75
                } else if (4400 <= feihuoliang) {
                    f = 12
                } else if (4280 <= feihuoliang) {
                    f = 11.7
                } else if (4160 <= feihuoliang) {
                    f = 11.4
                } else if (4040 <= feihuoliang) {
                    f = 11.1
                } else if (3920 <= feihuoliang) {
                    f = 10.8
                } else if (3800 <= feihuoliang) {
                    f = 10.5
                } else if (3680 <= feihuoliang) {
                    f = 10.2
                } else if (3560 <= feihuoliang) {
                    f = 9.9
                } else if (3440 <= feihuoliang) {
                    f = 9.6
                } else if (3320 <= feihuoliang) {
                    f = 9.3
                } else if (3200 <= feihuoliang) {
                    f = 9
                } else if (3030 <= feihuoliang) {
                    f = 7.5
                } else if (2860 <= feihuoliang) {
                    f = 6
                } else if (2690 <= feihuoliang) {
                    f = 4.5
                } else if (2520 <= feihuoliang) {
                    f = 3
                } else if (2350 <= feihuoliang) {
                    f = 1.5
                } else {
                    f = 0
                }
                // 引体向上计算
                switch (yinti) {
                    case 0:
                    case 1:
                    case 2:
                    case 3:
                    case 4:
                    case 5: yin = 0; break;
                    case 6: yin = 1; break
                    case 7: yin = 2; break
                    case 8: yin = 3; break
                    case 9: yin = 4; break
                    case 10: yin = 5; break
                    case 11: yin = 6; break
                    case 12: yin = 6.4; break
                    case 13: yin = 6.8; break
                    case 14: yin = 7.2; break
                    case 15: yin = 7.6; break
                    case 16: yin = 8; break
                    case 17: yin = 8.5; break
                    case 18: yin = 9; break
                    case 19: yin = 9.5; break
                    case 20: yin = 10; break
                    default: yin = 10; break
                }
                //50米跑
                if (duan <= 6.6) {
                    d = 20
                } else if (duan <= 6.7) {
                    d = 19
                } else if (duan <= 6.8) {
                    d = 18
                } else if (duan <= 6.9) {
                    d = 17
                } else if (duan <= 7) {
                    d = 16
                } else if (duan <= 7.2) {
                    d = 15.6
                } else if (duan <= 7.4) {
                    d = 15.2
                } else if (duan <= 7.6) {
                    d = 14.8
                } else if (duan <= 7.8) {
                    d = 14.4
                } else if (duan <= 8) {
                    d = 14
                } else if (duan <= 8.2) {
                    d = 13.6
                } else if (8.2 < duan <= 8.4) {
                    d = 13.2
                } else if (duan <= 8.6) {
                    d = 12.8
                } else if (duan <= 8.8) {
                    d = 12.4
                } else if (8.8 < duan <= 9) {
                    d = 12
                } else if (9 < duan <= 9.2) {
                    d = 10
                } else if (duan <= 9.4) {
                    d = 8
                } else if (duan <= 9.6) {
                    d = 6
                } else if (duan <= 9.8) {
                    d = 4
                } else if (duan <= 10) {
                    d = 2
                } else {
                    d = 0
                }
                if (!duan) {
                    d = 0
                }
                // 1000米长跑
                if (yuan <= 195) {
                    y = 20
                } else if (yuan <= 200) {
                    y = 19
                } else if (yuan <= 205) {
                    y = 18
                } else if (yuan <= 212) {
                    y = 17
                } else if (yuan <= 220) {
                    y = 16
                } else if (yuan <= 225) {
                    y = 15.6
                } else if (yuan <= 230) {
                    y = 15.2
                } else if (yuan <= 235) {
                    y = 14.8
                } else if (yuan <= 240) {
                    y = 14.4
                } else if (yuan <= 245) {
                    y = 14
                } else if (yuan <= 250) {
                    y = 13.6
                } else if (yuan <= 255) {
                    y = 13.2
                } else if (yuan <= 260) {
                    y = 12.8
                } else if (yuan <= 265) {
                    y = 12.4
                } else if (yuan <= 270) {
                    y = 12
                } else if (yuan <= 290) {
                    y = 10
                } else if (yuan <= 310) {
                    y = 8
                } else if (yuan <= 330) {
                    y = 6
                } else if (yuan <= 350) {
                    y = 4
                } else if (yuan <= 370) {
                    y = 2
                } else {
                    y = 0
                }
                if (!yuan) {
                    y = 0
                }
                // 立定跳远
                if (liding >= lidingArr1[0]) {
                    l = 10
                } else if (lidingArr1[1] <= liding) {
                    l = 9.5
                } else if (lidingArr1[2] <= liding) {
                    l = 9
                } else if (lidingArr1[3] <= liding) {
                    l = 8.5
                } else if (lidingArr1[4] <= liding) {
                    l = 8
                } else if (lidingArr1[5] <= liding) {
                    l = 7.8
                } else if (lidingArr1[6] <= liding) {
                    l = 7.6
                } else if (lidingArr1[7] <= liding) {
                    l = 7.4
                } else if (lidingArr1[8] <= liding) {
                    l = 7.2
                } else if (lidingArr1[9] <= liding) {
                    l = 7
                } else if (lidingArr1[10] <= liding) {
                    l = 6.8
                } else if (lidingArr1[11] <= liding) {
                    l = 6.6
                } else if (lidingArr1[12] <= liding) {
                    l = 6.4
                } else if (lidingArr1[13] <= liding) {
                    l = 6.2
                } else if (lidingArr1[14] <= liding) {
                    l = 6
                } else if (lidingArr1[15] <= liding) {
                    l = 5
                } else if (lidingArr1[16] <= liding) {
                    l = 4
                } else if (lidingArr1[17] <= liding) {
                    l = 3
                } else if (lidingArr1[18] <= liding) {
                    l = 2
                } else if (lidingArr1[19] <= liding) {
                    l = 1
                } else {
                    l = 0
                }
                // 坐位体前屈
                if (zuowei >= zuoweiArr1[0]) {
                    z = 10
                } else if (zuoweiArr1[1] <= zuowei) {
                    z = 9.5
                } else if (zuoweiArr1[2] <= zuowei) {
                    z = 9
                } else if (zuoweiArr1[3] <= zuowei) {
                    z = 8.5
                } else if (zuoweiArr1[4] <= zuowei) {
                    z = 8
                } else if (zuoweiArr1[5] <= zuowei) {
                    z = 7.8
                } else if (zuoweiArr1[6] <= zuowei) {
                    z = 7.6
                } else if (zuoweiArr1[7] <= zuowei) {
                    z = 7.4
                } else if (zuoweiArr1[8] <= zuowei) {
                    z = 7.2
                } else if (zuoweiArr1[9] <= zuowei) {
                    z = 7
                } else if (zuoweiArr1[10] <= zuowei) {
                    z = 6.8
                } else if (zuoweiArr1[11] <= zuowei) {
                    z = 6.6
                } else if (zuoweiArr1[12] <= zuowei) {
                    z = 6.4
                } else if (zuoweiArr1[13] <= zuowei) {
                    z = 6.2
                } else if (zuoweiArr1[14] <= zuowei) {
                    z = 6
                } else if (zuoweiArr1[15] <= zuowei) {
                    z = 5
                } else if (zuoweiArr1[16] <= zuowei) {
                    z = 4
                } else if (zuoweiArr1[17] <= zuowei) {
                    z = 3
                } else if (zuoweiArr1[18] <= zuowei) {
                    z = 2
                } else if (zuoweiArr1[19] <= zuowei) {
                    z = 1
                } else {
                    z = 0
                }
                // 求值bmi
                bmi = tizhong / Math.pow(shengao, 2)
                // BMI
                if (bmi >= 28) {
                    b = 9
                } else if (bmi >= 24) {
                    b = 12
                } else if (bmi >= 17.9) {
                    b = 15
                } else {
                    b = 12
                }
                if (!bmi) {
                    b = 0
                    bmi = 0
                }
                bmi = bmi.toFixed(2)
                zong = b + f + z + l + d + y + yin
            }
        }
        // 女生
        if (gender == 'remale') {
            let yangArr = [56, 54, 52, 49, 46, 44, 42, 40, 38, 36, 34, 32, 30, 28, 26, 24, 22, 20, 18, 16]
            let yangArr1 = [57, 55, 53, 50, 47, 45, 43, 41, 39, 37, 35, 33, 31, 29, 27, 25, 23, 21, 19, 17]
            if (nianji == 0 || nianji == 1) {
                //肺活量计算
                if (feihuoliang >= 3400) {
                    f = 15
                } else if (3350 <= feihuoliang) {
                    f = 14.25
                } else if (3300 <= feihuoliang) {
                    f = 13.5
                } else if (3150 <= feihuoliang) {
                    f = 12.75
                } else if (3000 <= feihuoliang) {
                    f = 12
                } else if (2900 <= feihuoliang) {
                    f = 11.7
                } else if (2800 <= feihuoliang) {
                    f = 11.4
                } else if (2700 <= feihuoliang) {
                    f = 11.1
                } else if (2600 <= feihuoliang) {
                    f = 10.8
                } else if (2500 <= feihuoliang) {
                    f = 10.5
                } else if (2400 <= feihuoliang) {
                    f = 10.2
                } else if (2300 <= feihuoliang) {
                    f = 9.9
                } else if (2200 <= feihuoliang) {
                    f = 9.6
                } else if (2100 <= feihuoliang) {
                    f = 9.3
                } else if (2000 <= feihuoliang) {
                    f = 9
                } else if (1960 <= feihuoliang) {
                    f = 7.5
                } else if (1920 <= feihuoliang) {
                    f = 6
                } else if (1880 <= feihuoliang) {
                    f = 4.5
                } else if (1840 <= feihuoliang) {
                    f = 3
                } else if (1800 <= feihuoliang) {
                    f = 1.5
                } else {
                    f = 0
                }
                //仰卧起坐
                if (yinti >= yangArr[0]) {
                    l = 10
                } else if (yangArr[1] <= yinti) {
                    l = 9.5
                } else if (yangArr[2] <= yinti) {
                    l = 9
                } else if (yangArr[3] <= yinti) {
                    l = 8.5
                } else if (yangArr[4] <= yinti) {
                    l = 8
                } else if (yangArr[5] <= yinti) {
                    l = 7.8
                } else if (yangArr[6] <= yinti) {
                    l = 7.6
                } else if (yangArr[7] <= yinti) {
                    l = 7.4
                } else if (yangArr[8] <= yinti) {
                    l = 7.2
                } else if (yangArr[9] <= yinti) {
                    l = 7
                } else if (yangArr[10] <= yinti) {
                    l = 6.8
                } else if (yangArr[11] <= yinti) {
                    l = 6.6
                } else if (yangArr[12] <= yinti) {
                    l = 6.4
                } else if (yangArr[13] <= yinti) {
                    l = 6.2
                } else if (yangArr[14] <= yinti) {
                    l = 6
                } else if (yangArr[15] <= yinti) {
                    l = 5
                } else if (yangArr[16] <= yinti) {
                    l = 4
                } else if (yangArr[17] <= yinti) {
                    l = 3
                } else if (yangArr[18] <= yinti) {
                    l = 2
                } else if (yangArr[19] <= yinti) {
                    l = 1
                } else {
                    l = 0
                }

                //50米跑
                if (duan <= 7.5) {
                    d = 20
                } else if (duan <= 7.6) {
                    d = 19
                } else if (duan <= 7.7) {
                    d = 18
                } else if (duan <= 8) {
                    d = 17
                } else if (duan <= 8.3) {
                    d = 16
                } else if (duan <= 8.5) {
                    d = 15.6
                } else if (duan <= 8.7) {
                    d = 15.2
                } else if (duan <= 8.9) {
                    d = 14.8
                } else if (duan <= 9.1) {
                    d = 14.4
                } else if (duan <= 9.3) {
                    d = 14
                } else if (duan <= 9.5) {
                    d = 13.6
                } else if (duan <= 9.7) {
                    d = 13.2
                } else if (duan <= 9.9) {
                    d = 12.8
                } else if (duan <= 10.1) {
                    d = 12.4
                } else if (duan <= 10.3) {
                    d = 12
                } else if (duan <= 10.5) {
                    d = 10
                } else if (duan <= 10.7) {
                    d = 8
                } else if (duan <= 10.9) {
                    d = 6
                } else if (duan <= 11.1) {
                    d = 4
                } else if (duan <= 11.3) {
                    d = 2
                } else {
                    d = 0
                }
                if (!duan) {
                    d = 0
                }
                // 1000米长跑
                if (yuan <= 198) {
                    y = 20
                } else if (yuan <= 204) {
                    y = 19
                } else if (yuan <= 210) {
                    y = 18
                } else if (yuan <= 217) {
                    y = 17
                } else if (yuan <= 224) {
                    y = 16
                } else if (yuan <= 229) {
                    y = 15.6
                } else if (yuan <= 234) {
                    y = 15.2
                } else if (yuan <= 239) {
                    y = 14.8
                } else if (yuan <= 244) {
                    y = 14.4
                } else if (yuan <= 249) {
                    y = 14
                } else if (yuan <= 254) {
                    y = 13.6
                } else if (yuan <= 259) {
                    y = 13.2
                } else if (yuan <= 264) {
                    y = 12.8
                } else if (yuan <= 269) {
                    y = 12.4
                } else if (yuan <= 274) {
                    y = 12
                } else if (yuan <= 284) {
                    y = 10
                } else if (yuan <= 294) {
                    y = 8
                } else if (yuan <= 304) {
                    y = 6
                } else if (yuan <= 314) {
                    y = 4
                } else if (yuan <= 324) {
                    y = 2
                } else {
                    y = 0
                }
                if (!yuan) {
                    y = 0
                }
                // 立定跳远
                if (liding >= lidingArr2[0]) {
                    l = 10
                } else if (lidingArr2[1] <= liding) {
                    l = 9.5
                } else if (lidingArr2[2] <= liding) {
                    l = 9
                } else if (lidingArr2[3] <= liding) {
                    l = 8.5
                } else if (lidingArr2[4] <= liding) {
                    l = 8
                } else if (lidingArr2[5] <= liding) {
                    l = 7.8
                } else if (lidingArr2[6] <= liding) {
                    l = 7.6
                } else if (lidingArr2[7] <= liding) {
                    l = 7.4
                } else if (lidingArr2[8] <= liding) {
                    l = 7.2
                } else if (lidingArr2[9] <= liding) {
                    l = 7
                } else if (lidingArr2[10] <= liding) {
                    l = 6.8
                } else if (lidingArr2[11] <= liding) {
                    l = 6.6
                } else if (lidingArr2[12] <= liding) {
                    l = 6.4
                } else if (lidingArr2[13] <= liding) {
                    l = 6.2
                } else if (lidingArr2[14] <= liding) {
                    l = 6
                } else if (lidingArr2[15] <= liding) {
                    l = 5
                } else if (lidingArr2[16] <= liding) {
                    l = 4
                } else if (lidingArr2[17] <= liding) {
                    l = 3
                } else if (lidingArr2[18] <= liding) {
                    l = 2
                } else if (lidingArr2[19] <= liding) {
                    l = 1
                } else {
                    l = 0
                }
                // 坐位体前屈
                if (zuowei >= zuoweiArr2[0]) {
                    z = 10
                } else if (zuoweiArr2[1] <= zuowei) {
                    z = 9.5
                } else if (zuoweiArr2[2] <= zuowei) {
                    z = 9
                } else if (zuoweiArr2[3] <= zuowei) {
                    z = 8.5
                } else if (zuoweiArr2[4] <= zuowei) {
                    z = 8
                } else if (zuoweiArr2[5] <= zuowei) {
                    z = 7.8
                } else if (zuoweiArr2[6] <= zuowei) {
                    z = 7.6
                } else if (zuoweiArr2[7] <= zuowei) {
                    z = 7.4
                } else if (zuoweiArr2[8] <= zuowei) {
                    z = 7.2
                } else if (zuoweiArr2[9] <= zuowei) {
                    z = 7
                } else if (zuoweiArr2[10] <= zuowei) {
                    z = 6.8
                } else if (zuoweiArr2[11] <= zuowei) {
                    z = 6.6
                } else if (zuoweiArr2[12] <= zuowei) {
                    z = 6.4
                } else if (zuoweiArr2[13] <= zuowei) {
                    z = 6.2
                } else if (zuoweiArr2[14] <= zuowei) {
                    z = 6
                } else if (zuoweiArr2[15] <= zuowei) {
                    z = 5
                } else if (zuoweiArr2[16] <= zuowei) {
                    z = 4
                } else if (zuoweiArr2[17] <= zuowei) {
                    z = 3
                } else if (zuoweiArr2[18] <= zuowei) {
                    z = 2
                } else if (zuoweiArr2[19] <= zuowei) {
                    z = 1
                } else {
                    z = 0
                }
                // 求值bmi
                bmi = tizhong / Math.pow(shengao, 2)
                // BMI
                if (bmi >= 28) {
                    b = 9
                } else if (bmi >= 24) {
                    b = 12
                } else if (bmi >= 17.2) {
                    b = 15
                } else {
                    b = 12
                }

                if (!bmi) {
                    b = 0
                    bmi = 0
                }
                bmi = bmi.toFixed(2)
                zong = b + f + z + l + d + y + yin
            } else {
                //肺活量计算
                if (feihuoliang >= 3450) {
                    f = 15
                } else if (3400 <= feihuoliang) {
                    f = 14.25
                } else if (3350 <= feihuoliang) {
                    f = 13.5
                } else if (3200 <= feihuoliang) {
                    f = 12.75
                } else if (3050 <= feihuoliang) {
                    f = 12
                } else if (2950 <= feihuoliang) {
                    f = 11.7
                } else if (2850 <= feihuoliang) {
                    f = 11.4
                } else if (2750 <= feihuoliang) {
                    f = 11.1
                } else if (2650 <= feihuoliang) {
                    f = 10.8
                } else if (2550 <= feihuoliang) {
                    f = 10.5
                } else if (2450 <= feihuoliang) {
                    f = 10.2
                } else if (2350 <= feihuoliang) {
                    f = 9.9
                } else if (2250 <= feihuoliang) {
                    f = 9.6
                } else if (2150 <= feihuoliang) {
                    f = 9.3
                } else if (2050 <= feihuoliang) {
                    f = 9
                } else if (2010 <= feihuoliang) {
                    f = 7.5
                } else if (1970 <= feihuoliang) {
                    f = 6
                } else if (1930 <= feihuoliang) {
                    f = 4.5
                } else if (1890 <= feihuoliang) {
                    f = 3
                } else if (1850 <= feihuoliang) {
                    f = 1.5
                } else {
                    f = 0
                }
                //仰卧起坐
                if (yinti >= yangArr1[0]) {
                    l = 10
                } else if (yangArr1[1] <= yinti) {
                    l = 9.5
                } else if (yangArr1[2] <= yinti) {
                    l = 9
                } else if (yangArr1[3] <= yinti) {
                    l = 8.5
                } else if (yangArr1[4] <= yinti) {
                    l = 8
                } else if (yangArr1[5] <= yinti) {
                    l = 7.8
                } else if (yangArr1[6] <= yinti) {
                    l = 7.6
                } else if (yangArr1[7] <= yinti) {
                    l = 7.4
                } else if (yangArr1[8] <= yinti) {
                    l = 7.2
                } else if (yangArr1[9] <= yinti) {
                    l = 7
                } else if (yangArr1[10] <= yinti) {
                    l = 6.8
                } else if (yangArr1[11] <= yinti) {
                    l = 6.6
                } else if (yangArr1[12] <= yinti) {
                    l = 6.4
                } else if (yangArr1[13] <= yinti) {
                    l = 6.2
                } else if (yangArr1[14] <= yinti) {
                    l = 6
                } else if (yangArr1[15] <= yinti) {
                    l = 5
                } else if (yangArr1[16] <= yinti) {
                    l = 4
                } else if (yangArr1[17] <= yinti) {
                    l = 3
                } else if (yangArr1[18] <= yinti) {
                    l = 2
                } else if (yangArr1[19] <= yinti) {
                    l = 1
                } else {
                    l = 0
                }

                //50米跑
                if (duan <= 7.4) {
                    d = 20
                } else if (duan <= 7.5) {
                    d = 19
                } else if (duan <= 7.6) {
                    d = 18
                } else if (duan <= 7.9) {
                    d = 1
                } else if (duan <= 8.2) {
                    d = 16
                } else if (duan <= 8.4) {
                    d = 15.6
                } else if (duan <= 8.6) {
                    d = 15.2
                } else if (duan <= 8.8) {
                    d = 14.8
                } else if (duan <= 9) {
                    d = 14.4
                } else if (duan <= 9.2) {
                    d = 14
                } else if (duan <= 9.4) {
                    d = 13.6
                } else if (duan <= 9.6) {
                    d = 13.2
                } else if (duan <= 9.8) {
                    d = 12.8
                } else if (duan <= 10) {
                    d = 12.4
                } else if (duan <= 10.2) {
                    d = 12
                } else if (duan <= 10.4) {
                    d = 10
                } else if (duan <= 10.6) {
                    d = 8
                } else if (duan <= 10.8) {
                    d = 6
                } else if (duan <= 11) {
                    d = 4
                } else if (duan <= 11.2) {
                    d = 2
                } else {
                    d = 0
                }
                if (!duan) {
                    d = 0
                }
                // 1000米长跑
                if (yuan <= 196) {
                    y = 20
                } else if (yuan <= 202) {
                    y = 19
                } else if (yuan <= 208) {
                    y = 18
                } else if (yuan <= 215) {
                    y = 17
                } else if (yuan <= 222) {
                    y = 16
                } else if (yuan <= 227) {
                    y = 15.6
                } else if (yuan <= 232) {
                    y = 15.2
                } else if (yuan <= 237) {
                    y = 14.8
                } else if (yuan <= 242) {
                    y = 14.4
                } else if (yuan <= 247) {
                    y = 14
                } else if (yuan <= 252) {
                    y = 13.6
                } else if (yuan <= 257) {
                    y = 13.2
                } else if (yuan <= 262) {
                    y = 12.8
                } else if (yuan <= 267) {
                    y = 12.4
                } else if (yuan <= 272) {
                    y = 12
                } else if (yuan <= 282) {
                    y = 10
                } else if (yuan <= 292) {
                    y = 8
                } else if (yuan <= 302) {
                    y = 6
                } else if (yuan <= 312) {
                    y = 4
                } else if (yuan <= 322) {
                    y = 2
                } else {
                    y = 0
                }
                if (!yuan) {
                    y = 0
                }
                // 立定跳远
                if (liding >= lidingArr3[0]) {
                    l = 10
                } else if (lidingArr3[1] <= liding) {
                    l = 9.5
                } else if (lidingArr3[2] <= liding) {
                    l = 9
                } else if (lidingArr3[3] <= liding) {
                    l = 8.5
                } else if (lidingArr3[4] <= liding) {
                    l = 8
                } else if (lidingArr3[5] <= liding) {
                    l = 7.8
                } else if (lidingArr3[6] <= liding) {
                    l = 7.6
                } else if (lidingArr3[7] <= liding) {
                    l = 7.4
                } else if (lidingArr3[8] <= liding) {
                    l = 7.2
                } else if (lidingArr3[9] <= liding) {
                    l = 7
                } else if (lidingArr3[10] <= liding) {
                    l = 6.8
                } else if (lidingArr3[11] <= liding) {
                    l = 6.6
                } else if (lidingArr3[12] <= liding) {
                    l = 6.4
                } else if (lidingArr3[13] <= liding) {
                    l = 6.2
                } else if (lidingArr3[14] <= liding) {
                    l = 6
                } else if (lidingArr3[15] <= liding) {
                    l = 5
                } else if (lidingArr3[16] <= liding) {
                    l = 4
                } else if (lidingArr3[17] <= liding) {
                    l = 3
                } else if (lidingArr3[18] <= liding) {
                    l = 2
                } else if (lidingArr3[19] <= liding) {
                    l = 1
                } else {
                    l = 0
                }
                // 坐位体前屈
                if (zuowei >= zuoweiArr3[0]) {
                    z = 10
                } else if (zuoweiArr3[1] <= zuowei) {
                    z = 9.5
                } else if (zuoweiArr3[2] <= zuowei) {
                    z = 9
                } else if (zuoweiArr3[3] <= zuowei) {
                    z = 8.5
                } else if (zuoweiArr3[4] <= zuowei) {
                    z = 8
                } else if (zuoweiArr3[5] <= zuowei) {
                    z = 7.8
                } else if (zuoweiArr3[6] <= zuowei) {
                    z = 7.6
                } else if (zuoweiArr3[7] <= zuowei) {
                    z = 7.4
                } else if (zuoweiArr3[8] <= zuowei) {
                    z = 7.2
                } else if (zuoweiArr3[9] <= zuowei) {
                    z = 7
                } else if (zuoweiArr3[10] <= zuowei) {
                    z = 6.8
                } else if (zuoweiArr3[11] <= zuowei) {
                    z = 6.6
                } else if (zuoweiArr3[12] <= zuowei) {
                    z = 6.4
                } else if (zuoweiArr3[13] <= zuowei) {
                    z = 6.2
                } else if (zuoweiArr3[14] <= zuowei) {
                    z = 6
                } else if (zuoweiArr3[15] <= zuowei) {
                    z = 5
                } else if (zuoweiArr3[16] <= zuowei) {
                    z = 4
                } else if (zuoweiArr3[17] <= zuowei) {
                    z = 3
                } else if (zuoweiArr3[18] <= zuowei) {
                    z = 2
                } else if (zuoweiArr3[19] <= zuowei) {
                    z = 1
                } else {
                    z = 0
                }
                // 求值bmi
                bmi = tizhong / Math.pow(shengao, 2)
                // BMI
                if (bmi >= 28) {
                    b = 9
                } else if (bmi >= 24) {
                    b = 12
                } else if (bmi >= 17.2) {
                    b = 15
                } else {
                    b = 12
                }

                if (!bmi) {
                    b = 0
                    bmi = 0
                }
                bmi = bmi.toFixed(2)
                zong = b + f + z + l + d + y + yin
            }
        }
        this.setData({
            userInfo: e.detail.value,
            zong,
            bmi
        })
    },
    //存档
    cundang() {
        console.log(app.status, 'cundang');
        if (app.status) {
            db.collection('userList').where({
                _openid: app.openID
            }).update({
                data: {
                    history: _.push(this.data.zong),
                    bmi: _.push(this.data.bmi)
                }
            })
        } else {
            wx.showToast({
                title: '请先登录！',
                icon: 'loading',
            }).then(res => {
                setTimeout(() => {
                    wx.switchTab({
                        url: '/pages/mine/index',
                    })
                }, 1000)

            })
        }
    },
    // 年级选择
    gradeChange(e) {
        this.setData({
            index: e.detail.value
        })
    },
    // 性别选择
    genderChange(e) {
        this.setData({
            gender: e.detail.value
        })
    },
    /**
     * 生命周期函数--监听页面加载
     */
    onLoad: function (options) {
        //请求数据库，用户信息
        wx.cloud.callFunction({
            name: 'getId',
        }).then(res => {
            app.openID = res.result.openid
            db.collection('userList').where({
                _openid: res.result.openid
            }).get().then(res => {
                app.data = res.data[0]
                console.log(res.data);
                if (res.data[0]) {
                    app.status = 1
                } else {
                    app.status = 0
                }
            })
        })
    },

    /**
     * 生命周期函数--监听页面初次渲染完成
     */
    onReady: function () {

    },

    /**
     * 生命周期函数--监听页面显示
     */
    onShow: function () {

    },

    /**
     * 生命周期函数--监听页面隐藏
     */
    onHide: function () {

    },

    /**
     * 生命周期函数--监听页面卸载
     */
    onUnload: function () {

    },

    /**
     * 页面相关事件处理函数--监听用户下拉动作
     */
    onPullDownRefresh: function () {

    },

    /**
     * 页面上拉触底事件的处理函数
     */
    onReachBottom: function () {

    },

    /**
     * 用户点击右上角分享
     */
    onShareAppMessage: function () {

    }
})